package WWW.SST.LIB;

import java.util.*;

/** 
 Teuzhu ��ժҪ˵����
*/
public class Teuzhu
{
	public Teuzhu()
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼� 
		//
	}


	public static ArrayList GetTeuzhuRecord(int uid, String status, String startTime, String EndTime, int Cpor, String datatype)
	{

//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String sql = " select  top 1000000 *    from daigouview ";
		if (uid == 0)
		{
			sql = sql + " where 1=1 ";
		}
		else
		{
			sql += " where hy_num=" + String.valueOf(uid);
		}

		if (status.equals("") || status.equals("���м�¼"))
		{
			sql += " and 1=1";
		}
		else if (status.equals("�Ѵ���"))
		{
			sql += " and (zt='δ�н�' or zt='�Ѷҽ�')  ";
		}
		else
		{
			if (status.equals("���н�"))
			{
				sql += " and zj_jiangjin>0  ";
			}
			else
			{
				sql += "  and zt='" + status + "' ";
			}
		}

		if (datatype.equals("tz"))
		{
			if (startTime.equals(""))
			{
				sql += " and 1=1";
			}
			else
			{
				sql += "  and addtime >= '" + startTime + " 00:00:00'";
			}

			if (EndTime.equals(""))
			{
				sql += " and 1=1";
			}
			else
			{
				sql += "  and addtime<='" + EndTime + " 23:59:59'";
			}

		}
		else //cp
		{
			if (startTime.equals(""))
			{
				sql += " and 1=1";
			}
			else
			{
				sql += "  and cp_time >= '" + startTime + " 00:00:00'";
			}

			if (EndTime.equals(""))
			{
				sql += " and 1=1";
			}
			else
			{
				sql += "  and cp_time<='" + EndTime + " 23:59:59'";
			}

		}



		if (Cpor == 0)
		{
			sql += " and 1=1";
		}
		else if (Cpor == 1)
		{
			sql += "  and cp_user not in (select [name]  from User_AdminList  )";
		}
		else
		{
			sql += "  and cp_user=(select [name]  from User_AdminList where id=" + String.valueOf(Cpor) + " )";
		}
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion

		sql += " order by id desc";
		DataTable d = MOLE.SQL.GetDataTable(sql);


		String Money = _GetTeuzhuRecordMoney(sql, status);


		ArrayList a = new ArrayList();
		a.add(d);
		a.add(Money);

		return a;

	}


	/** 
	 
	 
	 @param sql
	 @return 
	*/
	public static String _GetTeuzhuRecordMoney(String sql, String type)
	{
		String Money = "0.00";
		String sql2 = "select sum(totalprice) as HweizonMoney  from (" + sql + ") as t";
		if (type.equals("���н�"))
		{
			sql2 = "select sum(zj_jiangjin) as HweizonMoney  from (" + sql + ") as t";
		}


		DataTable dd = MOLE.SQL.GetDataTable(sql2);
		if (dd.Rows.size() != 0)
		{
			Money = (new Double(MOLE.str.ConvertToDouble(dd.Rows[0]["HweizonMoney"].toString()))).toString("0.00");
		}
		return Money;
	}


}